// Purpose: An exercise using Scanner, ArrayList, and Collections.sort.
//          Read words, sort them, print them.
package week05;
import java.util.*;


public class Alphabetize3 {
   public static void main(String[] args) {
    //... Declare variables.
Scanner    in   = new Scanner(System.in);
ArrayList<String> words = new ArrayList<String>();
 //... Read input one word at a time.



boolean condMaiContinuam = true;


do{

    System.out.println("Enter words. End with EOF (CTRL-Z Enter)");
 //... Read input one word at a time, adding it to an array list.
 String cuvant = new String();
 cuvant = in.next();
 words.add(cuvant);
 boolean estePunct=false;

 estePunct = cuvant.equalsIgnoreCase(".");

 if( estePunct ){
 System.out.println("Cuvant = Punct.");
 condMaiContinuam=false;
 }

} while (condMaiContinuam);
 //... Sort the words.
 Collections.sort(words);
 //... Print the sorted list.
 System.out.println("\n\nSorted words\n");

 for (String word : words) {
 System.out.println(word);
 }
 }
}










